#ifndef DYNAMICMODEL_H
#define DYNAMICMODEL_H

#include "arsexecitem.h"

class ObjectsIndex : public QObject
{
    Q_OBJECT

public:
    ObjectsIndex( QObject * parent );
    ~ObjectsIndex();
    ARSDummyForm * addForm( QString name, ARSExecItem * item = 0 );
    ARSDummyField * addField( ARSDummyForm * form, QString name, int id, ARSExecItem * item = 0 );
    ARSDummyActiveLink * addActiveLink( QString name, ARSExecItem * item = 0 );
    ARSDummyFilter * addFilter( QString name, ARSExecItem * item = 0 );
    ARSDummyGuide * addGuide( QString name, ARSExecWorkflowObject::ObjectType objectsType, ARSExecItem * item = 0 );
    ARSDummyObjectList objects( ARSObject::Types types ) const;
    ARSDummyObjectList & objects();
    void clear();
    void addRelation( ARSDummyObject * object, ARSExecItem * item );
    ARSExecItemList relatedItems( ARSDummyObject * object ) const;
    ARSDummyObject * findObject( const QString & name, ARSObject::Type type,
                                 ARSDummyForm * parentForm = 0,
                                 ARSExecWorkflowObject::ObjectType objectsType = ARSExecWorkflowObject::Unknown ) const;
    bool contains( ARSDummyObject * object, bool primaryOnly = true ) const;

private:
    QList<ARSDummyObject *> m_objectsList;
    QHash<ARSDummyObject *, ARSExecItem *> m_objectsHash;
};

class DynamicModel : public QObject
{
    Q_OBJECT

public:
    DynamicModel(ARSExecModelRootItem * rootItem, QObject * parent = 0);

    ARSExecModelRootItem * rootItem();
    ObjectsIndex * index() const;

private:
    ARSExecModelRootItem * m_rootItem;
    ObjectsIndex * m_index;
};

typedef QList<DynamicModel *> DynamicModelList;

#endif // DYNAMICMODEL_H
